<%@ page contentType="text/html;charset=utf-8"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.pojo.basic.Module" %>
<%@ include file="/default.jsp" %>
<%
List<Module> modules = (List<Module>)session.getAttribute("modules");
String   menus = "";
if(modules != null){
	for(Module module : modules){
		String flag = module.getUrl().equals("#")?"false":"true";
		String href = module.getUrl().equals("#")?"":module.getUrl()+"&moduleId="+module.getId();
		menus = menus + "{id:'"+module.getNo()+"',text:'"+module.getName()+"',href:'"+href+"',leaf:"+flag+"},";
	}
	menus = menus.substring(0,menus.length()-1);
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>GTC Content System</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script type="text/javascript" src="/Sunlike/js/homepage/homepage.js"></script>
<script type="text/javascript">
function tree(){
	var treeLoader = new Ext.tree.TreeLoader({
		dataUrl : "moduleAction.ajaxAllChildModule.action"
	}); 
	
	treeLoader.on('beforeload',function(treeLoader, node) {
		treeLoader.baseParams = {
	        p_no: ""+node.id,
	        date: new Date()
	    };
	}, this); 
	
	new Ext.tree.TreePanel({
		id:"user_acc_tree",
		renderTo: 'user_acc_contentel',
		animate:true,
		border:false,
		collapsible:false,
		rootVisible:false,
		autoScroll:false,
		autoHeight:true, 
		root: new Ext.tree.AsyncTreeNode({
			expanded: true,
			loader:treeLoader,
			children: [{id:'user_acc_work',
			    text: '我的工作台',
			    href:'homepage/my.jsp',
			    leaf: true
		    },<%= menus%> ]
		}),
		listeners:{click:function(node,event){
	   		event.stopEvent(); 
	   		var  contentTabPanel = Ext.getCmp("contentTabPanel"); 
	   		var  workTab  = contentTabPanel.getItem("tab-work");
	   		if (workTab&&node.leaf==true) {  
	   		   	contentTabPanel.remove(workTab,true);
	   			workTab = contentTabPanel.add({  
	            	id:'tab-work',  
	                title:node.text,  
	                closable:false,  
	                iconCls:'tab',
	                html:"<iframe id='frame_job' src='"+node.attributes.href+"' width='100%' height='100%' frameborder='0' scrolling='auto'></iframe>"
	            });  
	        }  
	   	 	contentTabPanel.setActiveTab(workTab); 
	   	}}
	});	  //new Ext.tree.TreePanel
} 
Ext.onReady(tree);
</script>
</head>

<body>
<div id="user_acc_contentel" >
</div>
</body>
</html>
